package cn.pn.project.client.comment;

import cn.pn.project.common.Page;
import cn.pn.project.pojo.comment.Comment;
import cn.pn.project.pojo.comment.Like;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 提供者提供的评论接口
 */
@FeignClient(name="pn-comment-provider")
public interface CommentFeign {

    /**
     * 根据评论id获取评论
     * @param commentId 评论id
     * @return
     * @throws Exception
     */
    @RequestMapping("/comment/commentById")
    Comment getCommentByCommentId(@RequestParam("commentId") Integer commentId) throws Exception;

    /**
     * 查询某个商品的所有主评论
     * @param commodityId
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping("/comment/listMain")
    Page<Comment> listMainComment(@RequestParam("commodityId") Integer commodityId,@RequestParam("pageNo")Integer pageNo,@RequestParam("pageSize")Integer pageSize);

    /**
     * 根据商品id查询主评论条数
     * @param commodityId 商品id
     * @return
     */
    @RequestMapping("/comment/mainCommentCount")
    Integer mainCommentCount(@RequestParam("commodityId") Integer commodityId);

    /**
     * 根据商品id查询该商品的主评论的子评论
     * @param belongToId 所属主评论id
     * @param commodityId 商品id
     * @return 某主评论的子评论的集合
     * @throws Exception
     */
    @RequestMapping("/comment/listChild")
    Page<Comment> listChildComment(@RequestParam("belongToId")Integer belongToId,@RequestParam("commodityId") Integer commodityId,@RequestParam("pageNo")Integer pageNo,@RequestParam("pageSize")Integer pageSize) throws Exception;

    /**
     * 根据用户id和商品id查询当前用户是否评论当前商品
     * @param userId 用户id
     * @param commodityId 商品id
     * @return 评论对象/null
     * @throws Exception
     */
    @RequestMapping("/comment/isCommentedOn")
    Comment isCommentedOn(@RequestParam("userId") Integer userId,@RequestParam("commodityId")Integer commodityId) throws Exception;
    /**
     * 添加主评论
     * @param comment 评论对象
     * @return 新评论对象/null
     * @throws Exception
     */
    @RequestMapping("/comment/addMain")
    Comment addMainComment(@RequestBody Comment comment) throws Exception;

    /**
     * 新增子评论
     * @param comment 评论对象
     * @return 0 1
     * @throws Exception
     */
    @RequestMapping("/comment/addChild")
    Integer addChildComment(@RequestBody Comment comment) throws Exception;

    /**
     * 根据评论id和图片id更新评论（只更新图片）
     * @param commentId 评论id
     * @param imgId 图片id
     * @return
     * @throws Exception
     */
    @RequestMapping("/comment/updateImg")
    Integer updateImgIdByCommentId(@RequestParam("commentId")Integer commentId, @RequestParam("imgId")Integer imgId) throws Exception;

    /**
     * 修改主评论
     * @param comment 评论对象
     * @return 修改后对象/null
     * @throws Exception
     */
    @RequestMapping("/comment/updateComment")
    Comment updateComment(@RequestBody  Comment comment) throws Exception;
    /**
     * 该用户该评论是否点赞
     * @param like
     * @return 0 1
     * @throws Exception
     */
    @RequestMapping("/comment/isLikedOn")
    Integer isLikedOn(@RequestParam("like") Like like) throws Exception;

    /**
     * 点赞
     * @param like
     * @return 0 1
     * @throws Exception
     */
    @RequestMapping("/comment/addLike")
    Integer addLike(@RequestParam("like") Like like) throws Exception;

    /**
     * 取消点赞
     * @param like
     * @return 0 1
     * @throws Exception
     */
    @RequestMapping("/comment/delLike")
    Integer delLike(@RequestParam("like") Like like) throws Exception;

    /**
     * 获得最大主键
     * @return
     * @throws Exception
     */
    @RequestMapping("/comment/max")
    Integer getMaxId() throws Exception;
}

